package StringPackage;

import org.junit.jupiter.api.Test;

/**
 * @author Lzm
 * @version 1.0
 */
public class reverseString_ {
  public static void main(String[] args) {
    char[] s = new char[]{'h','e','l','l','o','a'};
    System.out.println(s);
  }
  /*public static void reverseString(char[] s){
    int left = 0;
    int right = s.length - 1;
    while(left < right){
      char temp = s[left];
      s[left++] = s[right];
      s[right--] = temp;
    }
  }*/

  public void reverseString(char[] s) {
      int left = 0;
      int right = s.length - 1;
      while(left < right){
        char temp = s[left];
        s[left] = s[right];
        s[right] = temp;
        left++;
        right--;
      }
  }
}
